package com.yidu.service.impl;

import java.util.List;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.dao.SnMemberMapper;


import com.yidu.model.SnMember;

import com.yidu.service.SnMemberService;
/**
 * 
 * @ClassName: 会员的实现类
 * @Description: 描述
 * @author: ZhangHao
 * @date: 2018年12月17日 下午9:35:47
 */
@Service
public class SnMemberServiceImpl implements SnMemberService{
	/**
	 * 注入会员mapper
	 */
	@Resource
	SnMemberMapper memberMapper;

	
	@Override
	public List<SnMember> findAll(Map<String, Object> maps) {
		//查询所有的方法
		return memberMapper.findAll(maps);
	}

	@Override
	public int findCount(Map<String, Object> maps) {
		//调用查询行数的方法
		return memberMapper.findCount(maps);
	}

	@Override
	public int addOrUpdate(SnMember snmember) {
		//定义变量
		int row = 0;
		//如果会员id不为空
		if(snmember.getMeId() != null && !"".equals(snmember.getMeId())){
			//调用修改
			row = memberMapper.updateByPrimaryKeySelective(snmember);
		}else{
			//调用增加
			row = memberMapper.insertSelective(snmember);
		}
		//返回row
		return row;
	}
	
	@Override
	public int delete(String meId) {
		
		return memberMapper.deleteByPrimaryKey(meId);
	}

	@Override
	public int deleteByPrimaryKey(String meId) {
		return memberMapper.deleteByPrimaryKey(meId);
	}

	@Override
	public int insert(SnMember record) {
		return memberMapper.insert(record);
	}

	@Override
	public int insertSelective(SnMember record) {
		return memberMapper.insertSelective(record);
	}

	@Override
	public SnMember selectByPrimaryKey(String meId) {
		return memberMapper.selectByPrimaryKey(meId);
	}

	@Override
	public int updateByPrimaryKeySelective(SnMember record) {
		// TODO Auto-generated method stub
		return memberMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKey(SnMember record) {
		// TODO Auto-generated method stub
		return memberMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 根据电话查询会员
	 */
	@Override
	public SnMember findPhone(String phone) {
		//调用根据电话查询会员
		return memberMapper.findPhone(phone); 
	}

	
}
